import pygame


class Game:
    window = None
    W = 1600
    H = 900
    bg = None
    music = None
    index = 0
    tupian = None
    shengli = False
    player1 = None
    current_index = 0
    G = 0.5
    G_speed = 0
    speed = 4
    direction = None
    direction_W = False
    direction_A = False
    direction_S = False
    direction_D = False
    character_images = None
    current_images = None
    playerGroup = None

    player2 = None
    current_index2 = 0
    G2 = 0.5
    G_speed2 = 0
    speed2 = 4
    direction2 = None
    direction_W2 = False
    direction_A2 = False
    direction_S2 = False
    direction_D2 = False
    character_images2 = None
    current_images2 = None
    playerGroup2 = None
    fangkuai = False

    player3 = None
    current_index3 = 0
    G3 = 0.5
    G_speed3 = 0
    speed3 = 4
    direction3 = None
    direction_W3 = False
    direction_A3 = False
    direction_S3 = False
    direction_D3 = False
    character_images3 = None
    current_images3 = None
    playerGroup3 = None
    fangkuaixiaoshi = False
    zixinag_img = None
    player3_x = None
    player3_y = None


    player4 = None
    current_index4 = 0
    G4 = 0.1
    G_speed4 = 0
    speed4 = 1
    direction4 = None
    direction_W4 = False
    direction_A4 = False
    direction_S4 = False
    direction_D4 = False
    character_images4 = None
    current_images4 = None
    playerGroup4 = None

    wall = None
    BLOCK_SIZE = 50
    MAP_HEIGHT = 18
    MAP_WIDTH = 32
    wall_list = []

    # 音效
    jump_music = None
    fashe_music = None
    bullet = None
    bullet_list = []


    gem_number = None

    # 传送门
    portal = None
    mini_portal1 = None
    mini_portal2 = None
    # 怪物属性
    monster = None
    monster_list = []
    monster_number = len(monster_list)

    monster1_star = None
    monster1_end = None

    monster2_star = None
    monster2_end = None

    monster3_star = None
    monster3_end = None

    monster4_star = None
    monster4_end = None

    monster5_star = None
    monster5_end = None

    monster6_star = None
    monster6_end = None

    def __init__(self):
        Game.window = None
        Game.W = 1600
        Game.H = 900
        Game.index = 0
        Game.player1 = None
        Game.current_index = 0
        Game.G = 0.5
        Game.G_speed = 0
        Game.speed = 4
        Game.direction = None
        Game.direction_W = False
        Game.direction_A = False
        Game.direction_S = False
        Game.direction_D = False
        Game.character_images = None
        Game.current_images = None

        Game.playerGroup = pygame.sprite.Group()

        Game.wall = None
        Game.BLOCK_SIZE = 50
        Game.MAP_HEIGHT = 18
        Game.MAP_WIDTH = 32
        Game.wall_list = []

        Game.bullet = None
        Game.bullet_list = []

        # 初始化计数器
        count = 0
        Game.fangkuaixiaoshi = False
        # 遍历二维列表，找出所有的5并计数
        for row in Game.wall_list:
            for element in row:
                if element == 5:
                    count += 1

        for row in Game.wall_list:
            for element in row:
                if element == 6:
                    count += 1

        print(f"二维列表中值为5的元素数量为：{count}")

        Game.monster_list = [
            {"x": 450, "y": 50},
            {"x": 150, "y": 300},
            {"x": 950, "y": 250},
            {"x": 550, "y": 750},
            {"x": 750, "y": 500},
        ]
        Game.monster1_star = 250
        Game.monster1_end = 750

        Game.monster2_star = 150
        Game.monster2_end = 550

        Game.monster3_star = 950
        Game.monster3_end = 1250

        Game.monster4_star = 300
        Game.monster4_end = 700

        Game.monster5_star = 600
        Game.monster5_end = 1200

        Game.gem_number = count
